﻿using AutoMapper;
using Restful_Api.Entities;
using Restful_Api.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Restful_Api.ProFiles
{
    public class EmployeeProFile : Profile
    {
        public EmployeeProFile()
        {
            CreateMap<Employee, EmployeeDto>()
                .ForMember(dest => dest.Name, opt => opt.MapFrom(src => $"{src.FistName}{src.LastName}"))
                .ForMember(dest=>dest.GenderDisplay,opt=>opt.MapFrom(src=>src.Gender.ToString()))
                .ForMember(dest=>dest.Age,opt=>opt.MapFrom(src=>DateTime.Now.Day-src.DateOfBirth.Day));
            CreateMap<EmployeeAddDto, Employee>();
            CreateMap<EmployeeUpdateDto, Employee>();
            CreateMap<Employee, EmployeeUpdateDto>();
        }
    }
}
